#########################################
#Ideology, Populism, and Expropriation  #
#Replication Material                   #
#Authors: Stefano Jud & Dan Reiter      #
#Date: August 15, 2023                  #
#########################################

#####Preamble#####

rm(list = ls())

if (!require("pacman")) install.packages("pacman")

library(pacman)

pacman::p_load(tidyverse,lfe,readxl,stargazer,interflex,sandwich,lmtest,clubSandwich,fect,
               marginaleffects,brglm,survival,survminer,ggpubr,margins,PanelMatch,flextable,modelsummary,
               gtsummary) 


##### Load Data #####

main.df <- read_csv('Data//ReplicationData_II_JudReiter_230816.csv')


#####Figure 1#####

ggplot(data = main.df %>% dplyr::filter(year > 1989) %>% dplyr::mutate(pop.leader.blair = as.factor(pop.leader.blair)),
       aes(x=pop.leader.blair,y=exec.ecopref)) + 
  geom_boxplot(fill='grey',color='black') + scale_x_discrete(labels = c('0'='Non Populist','1'='Populist')) +
  xlab('Populist Ideology') + ylab('Left-Right Ideology') + ggtitle("Left-Right Ideology Difference Populist vs. Non-Populists") +  theme_bw()


ggsave('Figures//Figure1.jpeg',width = 7,height = 6)

#####Figure 2######
main.df <- main.df %>% mutate(region = if_else(region.fine.grained %in% c("North America","Central America","South America",'Oceania'),'Western Hemisphere',
                                               if_else(region.fine.grained %in% c("Western Europe","Eastern Europe"),'Europe',
                                                       if_else(region.fine.grained %in% c("West Africa","Central Africa","East Africa","Southern Africa","North Africa"),'Africa',
                                                               if_else(region.fine.grained == 'Middle East','Middle East','Asia')))))

fig2a <- ggplot(data = main.df %>% dplyr::filter(pop.leader.blair==1),aes(x=exec.ecopref)) + 
                geom_histogram(fill='grey',color='black',binwidth = 0.5) + 
                xlab('Left-Right Ideology') +ylab('Count') +
                ggtitle('Full Sample') +
                theme_bw()

fig2b <- ggplot(data = main.df %>% dplyr::filter(pop.leader.blair==1),aes(x=exec.ecopref)) + 
                geom_histogram(fill='grey',color='black',binwidth = 0.5) + 
                facet_wrap(.~region) +
                xlab('Left-Right Ideology') +ylab('Count') +
                ggtitle('By Region') +
                theme_bw()


ggpubr::ggarrange(fig2a,fig2b,nrow = 1,ncol = 2)

ggsave('Figures//Figure2.jpeg',width = 12,height = 7)


#####Figure 3######
main.df <- main.df %>% dplyr::mutate(rightist = if_else(exec.ecopref >= 0,1,0),
                                     type = if_else(pop.leader.blair == 1 & rightist ==1,'right_popul',
                                                    if_else(pop.leader.blair==1 & rightist == 0,'left_popul',
                                                            if_else(pop.leader.blair == 0 & rightist == 1,'right_nonpopul','left_nonpopul')))) 

exp.by.type <- main.df %>% filter(year > 1989) %>% group_by(type) %>% summarize(exp.events.dummy=sum(foreign.exp.dummy,na.rm = T)) %>% drop_na() %>% ungroup()

ggplot(data = exp.by.type,aes(x=type,y=exp.events.dummy)) + 
  geom_bar(stat='identity',color='black',fill='grey') + 
  scale_x_discrete(labels=c('Left Non-Populist','Left Populist',"Right Non-Populist",'Right Populist')) +
  ylab('Count Expropriations') + xlab('Gov. Ideology') + 
  theme_bw()

ggsave('Figures//Figure3.jpeg',width = 7,height = 6)


#####Table B1 (Appendix)######

#This table includes the main results. In the paper, figure 4 is based on the result from model test1d.int
#Models
test1a.int <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1|ccode.cow|0|ccode.cow,data = main.df)

test1b.int <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1|ccode.cow + year|0|ccode.cow,data = main.df)

test1c.int <- lfe::felm(foreign.exp.dummy ~pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp.lag1 +
                          gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1 + pop.land.ratio.lag1 
                        |ccode.cow + year|0|ccode.cow,data = main.df)

test1d.int <- lfe::felm(foreign.exp.dummy ~pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) + res_gdp.lag1  +
                          gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                          is.democ.lag1 + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data = main.df)

test1e.int <- lfe::felm(foreign.exp.dummy ~pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) + res_gdp.lag1  +
                          gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                          is.democ.lag1 + net.inforce.bits.lag1 |ccode.cow + region.year.fe|0|ccode.cow,data = main.df)


#Create Table

stargazer(test1a.int,test1b.int,test1c.int,test1d.int,test1e.int,type = 'html',title = 'Main Results Effects of Populism on Expropriation',
          label = 'res.pop.exp.interaction', keep.stat = c('n','rsq'),font.size = 'scriptsize',dep.var.caption = "",
          dep.var.labels = 'Foreign Expropriation Event',
          order = c(1,2,14,3,4,5,6,7,8,9,10,11,12,13),
          covariate.labels = c("Populist Leader$_{t-1}$","Economic Ideology$_{t-1}$","Populist Leader$_{t-1}$ X \\text{Economic Ideology}$_{t-1}$",
                               "Log Population$_{t-1}$","Log GDP$_{t-1}$","Natural Resource Rents/GDP$_{t-1}$","GDP Growth$_{t-1}$","FDI/GDP$_{t-1}$","Trade Openness$_{t-1}$","Active IMF Loan$_{t-1}$",
                               "Foreign Expropriation Event$_{t-1}$","Population/Land$_{t-1}$","Democracy$_{t-1}$","Num BITs Total$_{t-1}$"),
          add.lines = list(c('Country Fixed Effects','Yes','Yes','Yes','Yes','Yes'),c('Year Fixed Effects','No','Yes','Yes','Yes','No'),
                           c('Region-Year Fixed Effects','No','No','No','No','Yes')),
          out = 'Tables//Table_B1.doc')

#Calculate marginal effect of populism on expropriation (reported inside the text)
test1d.int.lm <- lm(foreign.exp.dummy ~pop.leader.blair.lag1*exec.ecopref.lag1+ log(pop.lag1) + log(gdp.lag1) + log(res_gdp.lag1+1)  +
                      gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                      is.democ.lag1 + net.inforce.bits.lag1 + factor(ccode.cow) + factor(year),data = main.df)

summary(margins(test1d.int.lm,vcov = vcovCR(test1d.int.lm,cluster = main.df$ccode.cow,type = 'CR2'),variables = 'pop.leader.blair.lag1'))



#####Figure 4######

#Define Marginal Effect Function

interaction_plot<- function(model, effect, moderator, interaction, varcov, at, conf=.95,miny,maxy,title,xlabel,ylabel){
  
  # Extract Variance Covariance matrix
  covMat = varcov
  
  # Extract the data frame of the model
  mod_frame = model.frame(model)
  
  # Get coefficients of variables
  beta_1 = model$coefficients[[effect]]
  beta_3 = model$coefficients[[interaction]]
  
  # Create list of moderator values at which marginal effect is evaluated
  x_2 <- at
  
  # Compute marginal effects
  delta_1 = beta_1 + beta_3*x_2
  
  # Compute variances
  var_1 = covMat[effect,effect] + (x_2^2)*covMat[interaction, interaction] + 2*x_2*covMat[effect, interaction]
  
  # Standard errors
  se_1 = sqrt(var_1)
  
  # Upper and lower confidence bounds
  z_score = qnorm(1 - ((1 - conf)/2))
  upper_bound = delta_1 + z_score*se_1
  lower_bound = delta_1 - z_score*se_1
  
  #Make Plot
  ggplot() + geom_line(aes(x=x_2,y=delta_1)) + geom_ribbon(aes(x=x_2,y=delta_1,ymin=lower_bound,ymax=upper_bound),alpha=0.5) + 
    geom_hline(yintercept = 0,linetype='dashed') + ylim(miny,maxy) + xlim(min(x_2),max(x_2)) +
    xlab(xlabel) + ylab(ylabel) + ggtitle(title) + theme_bw()
  
}

#Make Figure
interaction_plot(test1d.int,1,2,14,
                 varcov = test1d.int$clustervcv,at=seq(min(main.df$exec.ecopref.lag1,na.rm = T),max(main.df$exec.ecopref.lag1,na.rm = T),0.1), 
                 maxy = 0.4,miny = -0.2,title = '',
                 xlabel = "Left-Right Ideology", ylabel = 'Marginal Effect of Populist Leader on Probability of Expropriation') 

ggsave('Figures//Figure4.jpeg',width = 8,height = 6)


#####Table 2######

mech1.res.blair <- lfe::felm(foreign.exp.dummy ~ left_pop_blair.lag1*log(res_gdp.lag1) +  foreign.exp.dummy.lag1 + net.inforce.bits.lag1.ihs + log(pop.lag1) + log(gdp.lag1) +
                               gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ pop.land.ratio.lag1 + 
                               is.democ.lag1   |ccode.cow + year|0|ccode.cow,data = main.df)

mech2.growth.blair <- lfe::felm(foreign.exp.dummy ~ left_pop_blair.lag1*gdp.growth.wb.lag1 + log(res_gdp.lag1) +  foreign.exp.dummy.lag1 + net.inforce.bits.lag1.ihs + log(pop.lag1) + log(gdp.lag1) +
                                  fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ pop.land.ratio.lag1 + 
                                  is.democ.lag1   |ccode.cow + year|0|ccode.cow,data = main.df)

mech1.res.dpi <- lfe::felm(foreign.exp.dummy ~ left_pop_dpi.lag1*log(res_gdp.lag1) +  foreign.exp.dummy.lag1 + net.inforce.bits.lag1.ihs + log(pop.lag1) + log(gdp.lag1) +
                             gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ pop.land.ratio.lag1 + 
                             is.democ.lag1   |ccode.cow + year|0|ccode.cow,data = main.df)

mech2.growth.dpi <- lfe::felm(foreign.exp.dummy ~ left_pop_dpi.lag1*gdp.growth.wb.lag1 + log(res_gdp.lag1) +  foreign.exp.dummy.lag1 + net.inforce.bits.lag1.ihs + log(pop.lag1) + log(gdp.lag1) +
                                fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ pop.land.ratio.lag1 + 
                                is.democ.lag1   |ccode.cow + year|0|ccode.cow,data = main.df)


stargazer(mech1.res.blair,mech1.res.dpi,mech2.growth.blair,mech2.growth.dpi,type = 'html',
          title = 'Costs of Expropriation Moderate Left Populists Propensity to Expropriate',
          omit = c('net.inforce.bits.lag1', 'foreign.exp.dummy.lag1',
                   "log.pop.lag1",'log.gdp.lag1','fdi.gdp.lag1','trade.openness.lag1',
                   'active.imfloans.lag1','pop.land.ratio.lag1','is.democ.lag1'),
          label = 'cost_exp', keep.stat = c('n','rsq'),font.size = 'scriptsize',dep.var.caption = "",dep.var.labels.include = F,
          column.labels = c('Nat. Resources','Nat. Resources','Growth','Growth'),no.space = T,
          covariate.labels = c("Left Populist Leader (Blair)$_{t-1}$","Left Populist Leader (DPI)$_{t-1}$","Log Natural Resource Rents/GDP$_{t-1}$",
                               "GDP Growth$_{t-1}$",
                               "Left Populist Leader (Blair)$_{t-1}$ X \\text{Log Natural Resource Rents/GDP}$_{t-1}$",
                               "Left Populist Leader (DPI)$_{t-1}$ X \\text{Log Natural Resource Rents/GDP}$_{t-1}$",
                               "Left Populist Leader (Blair)$_{t-1}$ X \\text{GDP Growth}$_{t-1}$",
                               "Left Populist Leader (DPI)$_{t-1}$ X \\text{GDP Growth}$_{t-1}$"),
          add.lines = list(c('Country Fixed Effects','Yes','Yes','Yes','Yes'),
                           c('Year Fixed Effects','Yes','Yes','Yes','Yes'),
                           c('Main Control Variables','Yes','Yes','Yes','Yes')),
          out = 'Tables//Table2.doc')

##########################################
##### Replication Appendix Material ######
##########################################

#####Figure A1 (Appendix)######

main.df <- main.df %>% mutate(year = as.integer(year)) 
DisplayTreatment(unit.id = 'ccode.wb',time.id = 'year',treatment = 'pop.leader.blair',data = as.data.frame(main.df),
                 title = "Periods with Populist Leaders", legend.position = 'right',
                 legend.labels = c("No Populists", "Populists"),xlab = 'Year',ylab = 'Country')

ggsave('Figures//FigureA1.jpeg',width = 14,height = 12)


#####Table A1 (Appendix)######
covs.models <- c('foreign.exp.dummy','pop.leader.blair.lag1','exec.ecopref.lag1','net.inforce.bits.lag1.ihs',
                 "log.pop.lag1",'log.gdp.lag1', 'log.res_gdp.lag1','gdp.growth.wb.lag1','fdi.gdp.lag1','trade.openness.lag1',
                 'active.imfloans.lag1','pop.land.ratio.lag1','is.democ.lag1')

desc.df <- main.df %>% dplyr::filter(year > 1989)%>% dplyr::select(all_of(covs.models)) %>% as.data.frame()

stargazer(desc.df,type = 'html',covariate.labels = c("Foreign Expropriation Event","Populist Leader$_{t-1}$","Economic Ideology$_{t-1}$","Num BITs Total$_{t-1}$",
                                                     "Log Population$_{t-1}$","Log GDP$_{t-1}$","GDP Growth$_{t-1}$","FDI/GDP$_{t-1}$","Trade Openness$_{t-1}$",
                                                     "Log Natural Resource Rents/GDP$_{t-1}$","Active IMF Loan$_{t-1}$",
                                                     "Population/Land$_{t-1}$","Democracy$_{t-1}$"),
          out = 'Tables//TableA1.doc')


#####Table B2 (Appendix)######

#Models
test1e <- lfe::felm(foreign.exp.dummy ~ exec.popul.lag1*exec.ecopref.lag1+ log(pop.lag1) + log(gdp.lag1) + res_gdp_ihs.lag1 +
                      gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                      is.democ.lag1  + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data = main.df)

test1f <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*coal.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp_ihs.lag1 +
                      gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                      is.democ.lag1  + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data = main.df)

test1g <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*execrlc.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp_ihs.lag1 +
                      gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                      is.democ.lag1  + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data = main.df)

test1l <- lfe::felm(foreign.exp.dummy ~ left_pop_dpi.lag1 + log(pop.lag1) + log(gdp.lag1) + foreign.exp.dummy.lag1 +res_gdp_ihs.lag1 +
                      gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1  + pop.land.ratio.lag1+
                      is.democ.lag1  + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data = main.df)


#Make Table
stargazer(test1e,test1f,test1g,test1l,type = 'html',title = 'Effect of Populism on Expropriation using Alternative Measures of IVs',
          label = 'res.pop.exp.interaction', keep.stat = c('n','rsq'),font.size = 'scriptsize',dep.var.caption = "",
          dep.var.labels = 'Foreign Expropriation Event',no.space = T,
          order = c(1,2,18,3,4,19,5,20,6,7,8,9,10,11,12,13,14,15,16,17),
          covariate.labels = c("Populist Ideology V-Party$_{t-1}$","Economic Ideology$_{t-1}$",
                               "Populist Ideology V-Party$_{t-1}$ X \\text{Economic Ideology}$_{t-1}$","Populist Leader$_{t-1}$","Economic Ideology (Coalition)$_{t-1}$",
                               "Populist Leader$_{t-1}$ X \\text{Economic Ideology (Coalition)}$_{t-1}$","Economic Ideology DPI$_{t-1}$",
                               "Populist Leader$_{t-1}$ X \\text{Economic Ideology DPI}$_{t-1}$","Left Populist Dummy (DPI)$_{t-1}$",
                               "Log Population$_{t-1}$","Log GDP$_{t-1}$","Natural Resource Rents/GDP$_{t-1}$","GDP Growth$_{t-1}$","FDI/GDP$_{t-1}$","Trade Openness$_{t-1}$","Active IMF Loan$_{t-1}$",
                               "Foreign Expropriation Event$_{t-1}$","Population/Land$_{t-1}$","Democracy$_{t-1}$","Num BITs Total$_{t-1}$"),
          add.lines = list(c('Country Fixed Effects','Yes','Yes','Yes','Yes'),c('Year Fixed Effects','No','Yes','Yes','Yes')),
          out = 'Tables//TableB2.doc')


#####Table B3 (Appendix)######

##Models

#Sub-sample: Only countries that had at least once a leftist populist government
ccode.lp <- main.df %>% group_by(ccode.cow) %>% summarise(mean.treat = mean(pop.leader.blair,na.rm =T)) %>% drop_na() %>% filter(mean.treat > 0 & mean.treat < 1) %>%
  dplyr::pull(.,ccode.cow)

test1h <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp.lag1 +
                      gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ foreign.exp.dummy.lag1 + pop.land.ratio.lag1 +
                      is.democ.lag1  + net.inforce.bits.lag1|ccode.cow + year|0|ccode.cow,data = main.df  %>% dplyr::filter(ccode.cow %in% ccode.lp))

#Sub-sample: No South american countries
test1i.nonLA <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp.lag1 +
                            gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ foreign.exp.dummy.lag1 + pop.land.ratio.lag1 +
                            is.democ.lag1  + net.inforce.bits.lag1|ccode.cow + year|0|ccode.cow,data = filter(main.df,region.fine.grained != 'South America'))

#Sub-sample: Only South american countries
test1i.onlyLA <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp.lag1 +
                             gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ foreign.exp.dummy.lag1 + pop.land.ratio.lag1 +
                             is.democ.lag1  + net.inforce.bits.lag1|ccode.cow + year|0|ccode.cow,data = filter(main.df,region.fine.grained == 'South America'))

#Sub-sample: No Eastern European countries
test1i.nonEE <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp.lag1 +
                            gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ foreign.exp.dummy.lag1 + pop.land.ratio.lag1 +
                            is.democ.lag1  + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data = filter(main.df,region.fine.grained != "Eastern Europe"))

#Sub-sample: No Venezuela
test1i.nonVEN <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp.lag1 +
                             gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ foreign.exp.dummy.lag1 + pop.land.ratio.lag1 +
                             is.democ.lag1  + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data = filter(main.df,ccode.cow != 101))


##Make Table
stargazer(test1h,test1i.nonLA,test1i.onlyLA,test1i.nonEE,test1i.nonVEN,type = 'html',title = 'Effect of Populism on Expropriation in Different Sub-Samples',
          label = 'res.pop.exp.subsamp', keep.stat = c('n','rsq'),font.size = 'scriptsize',dep.var.caption = "",
          dep.var.labels = 'Sub-Samples', column.labels = c('Populist Hist.','Non-Latin','Only Latin','No EE','No VEN'),
          order = c(1,2,14,3,4,5,6,7,8,9,10,11,12,13),no.space = T,
          covariate.labels = c("Populist Leader$_{t-1}$","Economic Ideology$_{t-1}$","Populist Leader$_{t-1}$ X \\text{Economic Ideology}$_{t-1}$",
                               "Log Population$_{t-1}$","Log GDP$_{t-1}$","Natural Resource Rents/GDP$_{t-1}$","GDP Growth$_{t-1}$","FDI/GDP$_{t-1}$","Trade Openness$_{t-1}$","Active IMF Loan$_{t-1}$",
                               "Foreign Expropriation Event$_{t-1}$","Population/Land$_{t-1}$","Democracy$_{t-1}$","Num BITs Total$_{t-1}$"),
          add.lines = list(c('Country Fixed Effects','Yes','Yes','Yes','Yes','Yes'),c('Year Fixed Effects','Yes','Yes','Yes','Yes','Yes')),
          out = 'Tables//TableB3.doc')


#####Table B4 (Appendix)######

##Models
#Added CV: Communist Dummy
test1i.commies <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp.lag1 +
                              gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ foreign.exp.dummy.lag1 + pop.land.ratio.lag1 +
                              is.democ.lag1  + net.inforce.bits.lag1 + communist_dummy.lag1|ccode.cow + year|0|ccode.cow,data = main.df)

#Added CV: Legislative Constraints (Esberg & Perlman)
test1i.legcon <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp.lag1 +
                             gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ foreign.exp.dummy.lag1 + pop.land.ratio.lag1 +
                             net.inforce.bits.lag1 + leg_con_vdem.lag1|ccode.cow + year|0|ccode.cow,data = main.df)

#Added CV: Vertical Accountability (Esberg & Perlman)
test1i.veraccount <- lfe::felm(foreign.exp.dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) +res_gdp.lag1 +
                                 gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ foreign.exp.dummy.lag1 + pop.land.ratio.lag1 +
                                 net.inforce.bits.lag1 +vert_acc_vdem.lag1 |ccode.cow + year|0|ccode.cow,data = main.df)

#Make Table
stargazer(test1i.commies,test1i.legcon,test1i.veraccount,type = 'html',title = 'Main Results Including Different Control Variables',
          label = 'res.pop.exp.subsamp', keep.stat = c('n','rsq'),font.size = 'scriptsize',dep.var.caption = "",
          dep.var.labels = '', column.labels = c('Former Communist','Leg. Constraint','Vert. Accountability'),
          order = c(1,2,17,3,4,5,6,7,8,9,10,11,12,13,14,15,16),no.space = T,
          covariate.labels = c("Populist Leader$_{t-1}$","Economic Ideology$_{t-1}$","Populist Leader$_{t-1}$ X \\text{Economic Ideology}$_{t-1}$",
                               "Log Population$_{t-1}$","Log GDP$_{t-1}$","Natural Resource Rents/GDP$_{t-1}$","GDP Growth$_{t-1}$","FDI/GDP$_{t-1}$","Trade Openness$_{t-1}$","Active IMF Loan$_{t-1}$",
                               "Foreign Expropriation Event$_{t-1}$","Population/Land$_{t-1}$","Democracy$_{t-1}$","Num BITs Total$_{t-1}$",'Former Communist$_{t-1}$',
                               'V-Dem Legislative Constraints$_{t-1}$', 'Vertical Accountability$_{t-1}$'),
          add.lines = list(c('Country Fixed Effects','Yes','Yes','Yes'),c('Year Fixed Effects','Yes','Yes','Yes')),
          out = 'Tables//TableB4.doc')


#####Table B5 (Appendix)######

#Cox Model Approach
surv1a <- survival::coxph(Surv(t0, t1, foreign.exp.dummy) ~pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) + log.res_gdp.lag1 +
                            gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1+ foreign.exp.dummy.lag1 + pop.land.ratio.lag1 +
                            is.democ.lag1 + net.inforce.bits.lag1 + cluster(ccode.cow),
                          data = main.df)

#Make Table
modelsummary::modelsummary(surv1a,stars = c('*' = .1, '**' = .05,'***'=.01),
                           coef_rename = c('pop.leader.blair.lag1'="Populist Leader",'exec.ecopref.lag1'="Economic Ideology",
                                           'log(pop.lag1)'="Log Population", 'log(gdp.lag1)'="Log GDP", 
                                           'gdp.growth.wb.lag1' = "GDP Growth", 'log.res_gdp.lag1'="Log Natural Resource Rents/GDP",
                                           'fdi.gdp.lag1'="FDI/GDP",'trade.openness.lag1'='Trade Openness', 'active.imfloans.lag1'="Active IMF Loans",
                                           'foreign.exp.dummy.lag1'='Lagged Foreign Expropriation Event',
                                           'pop.land.ratio.lag1' = "Population/Land ",'is.democ.lag1'='Democracy','net.inforce.bits.lag1'='Num BITs Total',
                                           'pop.leader.blair.lag1:exec.ecopref.lag1' = "Populist Leader X Economic Ideology"),
                           output = "Tables//TableB5.docx")

#Alternative Table 
surv1a %>% tbl_regression(exponentiate=TRUE,
                          label= list(pop.leader.blair.lag1~"Populist Leader",exec.ecopref.lag1~"Economic Ideology",
                                      `log(pop.lag1)`~"Log Population", `log(gdp.lag1)`~"Log GDP", 
                                      gdp.growth.wb.lag1 ~ "GDP Growth", log.res_gdp.lag1~"Log Natural Resource Rents/GDP",
                                      fdi.gdp.lag1~"FDI/GDP",trade.openness.lag1~'Trade Openness', active.imfloans.lag1~"Active IMF Loans",
                                      foreign.exp.dummy.lag1~'Lagged Foreign Expropriation Event',
                                      pop.land.ratio.lag1 ~ "Population/Land ",is.democ.lag1~'Democracy',net.inforce.bits.lag1~'Num BITs Total')) %>% 
  add_glance_source_note() %>% modify_header(label~"**Variable**")

#####Figure B1 (Appendix)######

#Subset data to observations with common support on Ideology Scale
maxmin.ideo <- main.df %>% filter(pop.leader.blair==1) %>% summarize(maxIdeo = max(exec.ecopref.lag1,na.rm=T),
                                                                     minIdeo = min(exec.ecopref.lag1,na.rm = T)) %>% as.matrix()


csupp.main.df <- main.df %>% dplyr::filter(exec.ecopref.lag1 < maxmin.ideo[1] & exec.ecopref.lag1 > maxmin.ideo[2])

#Make figure
interflex(estimator = 'raw',Y='foreign.exp.dummy',D='pop.leader.blair.lag1',X='exec.ecopref.lag1',data = as.data.frame(csupp.main.df),na.rm = T,
          Xlabel ='Left-Right Ideology',theme.bw = T, Ylabel = 'Probability of Expropriation of Foreing Assests')

ggsave('Figures//FigureB1.jpg',width = 7,height = 6)

#####Figure B2 (Appendix)######

covs.model1 <-  c('net.inforce.bits.lag1', 'foreign.exp.dummy.lag1',
                  "log.pop.lag1",'log.gdp.lag1', 'gdp.growth.wb.lag1','fdi.gdp.lag1','trade.openness.lag1','log.res_gdp.lag1',
                  'active.imfloans.lag1','pop.land.ratio.lag1','is.democ.lag1')

interflex(Y = "foreign.exp.dummy", D = "pop.leader.blair.lag1", X = "exec.ecopref.lag1", Z=covs.model1,data = as.data.frame(main.df), estimator = "binning", FE = c("ccode.cow", "year"), cl = "ccode.cow",na.rm = T,
          xlab ='Left-Right Ideology',theme.bw = T, ylab = 'Probability of Expropriation of Foreing Assests')

ggsave('Figures//FigureB2.jpg',width = 7,height = 6)


#####Figure B3 (Appendix)######
#Note: The Kernel estimator can take up 10mins to run the analysis
set.seed(1234)
interflex(Y = "foreign.exp.dummy", D = "pop.leader.blair.lag1", X = "exec.ecopref.lag1", Z=covs.model1,data = as.data.frame(csupp.main.df), estimator = "kernel", FE = c("ccode.cow", "year"), cl = "ccode.cow",na.rm = T,
          xlab ='Left-Right Ideology',theme.bw = T, ylab = 'Probability of Expropriation of Foreing Assests')

ggsave('Figures//FigureB3.jpg',width = 7,height = 6)


#####Figure B4 (Appendix)######
#Ideology Squared Model
test1d.int.cs.sq <- lfe::felm(foreign.exp.dummy ~pop.leader.blair.lag1*I(exec.ecopref.lag1^2) + pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) + res_gdp.lag1  +
                                gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                                is.democ.lag1 + net.inforce.bits.lag1|ccode.cow + year|0|ccode.cow,data = csupp.main.df)


#Define Plotting Function
interaction_plot.sq<- function(model,b3,b4,b5, varcov, at, conf=.95,miny,maxy,title,xlabel,ylabel){
  
  # Extract Variance Covariance matrix
  covMat = varcov
  
  # Extract the data frame of the model
  mod_frame = model.frame(model)
  
  # Get coefficients of variables
  beta_1 = model$coefficients[[b3]]
  beta_3 = model$coefficients[[b4]]
  beta_5 = model$coefficients[[b5]]
  
  # Create list of moderator values at which marginal effect is evaluated
  x_2 <- at
  
  # Compute marginal effects
  delta_1 = beta_1 + beta_3*x_2 + beta_5*x_2^2
  
  # Compute variances
  var_1 = covMat[b3,b3] + (x_2^2)*covMat[b4, b4] + (x_2^4)*covMat[b5, b5] + 2*x_2*covMat[b3, b4] + 2*x_2^2*covMat[b3, b5] + 2*x_2^3*covMat[b4, b5]
  
  # Standard errors
  se_1 = sqrt(var_1)
  
  # Upper and lower confidence bounds
  z_score = qnorm(1 - ((1 - conf)/2))
  upper_bound = delta_1 + z_score*se_1
  lower_bound = delta_1 - z_score*se_1
  
  #Make Plot
  ggplot() + geom_line(aes(x=x_2,y=delta_1)) + geom_ribbon(aes(x=x_2,y=delta_1,ymin=lower_bound,ymax=upper_bound),alpha=0.5) + 
    geom_hline(yintercept = 0,linetype='dashed') + ylim(miny,maxy) + xlim(min(x_2),max(x_2)) +
    xlab(xlabel) + ylab(ylabel) + ggtitle(title) + theme_bw()
  
}

#Make Figure
interaction_plot.sq(test1d.int.cs.sq,1,16,15,
                    varcov = test1d.int.cs.sq$clustervcv,at=seq(min(csupp.main.df$exec.ecopref.lag1,na.rm = T),max(csupp.main.df$exec.ecopref.lag1,na.rm = T),0.1), 
                    maxy = 1,miny = -0.2,title = '',
                    xlabel = "Left-Right Ideology", ylabel = 'Marginal Effect of Populist Leader on Probability of Expropriation') 


ggsave('Figures//FigureB4.jpg',width = 7,height = 5)


#####Table B6 (Appendix)######
test1d.int.cs <- lfe::felm(foreign.exp.dummy ~pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) + res_gdp.lag1  +
                             gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                             is.democ.lag1 + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data = csupp.main.df)

stargazer(test1d.int.cs,type = 'html',title = 'Effect of Populism on Expropriation Likelihood with Data satisfying Common Support Assumption',
          label = 'res.pop.exp.interaction.cs', keep.stat = c('n','rsq'),font.size = 'scriptsize',dep.var.caption = "",
          dep.var.labels = 'Foreign Expropriation Event', no.space = T,
          order = c(1,2,14,3,4,5,6,7,8,9,10,11,12,13), 
          covariate.labels = c("Populist Leader$_{t-1}$","Economic Ideology$_{t-1}$","Populist Leader$_{t-1}$ X \\text{Economic Ideology}$_{t-1}$",
                               "Log Population$_{t-1}$","Log GDP$_{t-1}$","Natural Resource Rents/GDP$_{t-1}$","GDP Growth$_{t-1}$","FDI/GDP$_{t-1}$","Trade Openness$_{t-1}$","Active IMF Loan$_{t-1}$",
                               "Foreign Expropriation Event$_{t-1}$","Population/Land$_{t-1}$","Democracy$_{t-1}$","Num BITs Total$_{t-1}$"),
          add.lines = list(c('Country Fixed Effects','Yes'),c('Year Fixed Effects','Yes')),
          out = 'Tables//TableB6.doc')



#####Table B7 (Appendix)######
##Models
#Note the brglm model to account for rare events takes a bit longer to compile.
rare.logit <- brglm(foreign.exp.dummy ~pop.leader.blair.lag1*exec.ecopref.lag1+ + log(pop.lag1) + log(gdp.lag1) + log.res_gdp.lag1 +
                      gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                      is.democ.lag1 + net.inforce.bits.lag1 + factor(ccode.cow) + factor(year), family=binomial(link="logit"), method = "brglm.fit", p1 = T, data = as.data.frame(main.df))

clust.rob <- coef_test(rare.logit,vcovCR(rare.logit,cluster = main.df$ccode.cow,type = 'CR2'))

regular.logit <- glm(foreign.exp.dummy ~pop.leader.blair.lag1*exec.ecopref.lag1+ + log(pop.lag1) + log(gdp.lag1) + log.res_gdp.lag1 +
                       gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                       is.democ.lag1 + net.inforce.bits.lag1, family=binomial(link="logit"), data = as.data.frame(main.df))

clust.rob_reg.logit <- coef_test(regular.logit,vcovCR(regular.logit,cluster = main.df$ccode.cow,type = 'CR2'))

#Make Table
stargazer(rare.logit,regular.logit,type = 'html',title = 'Models Accounting for Limited Dependent Variable',
          omit = c('ccode.cow','year'),font.size = 'scriptsize',dep.var.caption = "",
          dep.var.labels = 'Foreign Expropriation Dummy',
          model.names = F,
          column.labels = c('Penalized ML Estimation','Logit Model'),
          order = c(1,2,182,3,4,5,6,7,8,9,10,11,12,13),no.space = T,
          se=list(clust.rob[,3],clust.rob_reg.logit[,3]),p=list(clust.rob[,6],clust.rob_reg.logit[,6]),
          covariate.labels = c("Populist Leader$_{t-1}$","Economic Ideology$_{t-1}$","Populist Leader$_{t-1}$ X \\text{Economic Ideology}$_{t-1}$",
                               "Log Population$_{t-1}$","Log GDP$_{t-1}$","Natural Resource Rents/GDP$_{t-1}$","GDP Growth$_{t-1}$","FDI/GDP$_{t-1}$","Trade Openness$_{t-1}$","Active IMF Loan$_{t-1}$",
                               "Foreign Expropriation Event$_{t-1}$","Population/Land$_{t-1}$","Democracy$_{t-1}$","Num BITs Total$_{t-1}$"),
          out = 'Tables//TableB7.doc')


#####Table B8 (Appendix)######

main.df$korbin_all_dummy <- if_else(main.df$korbin_cov_exp_dummy == 1 | main.df$korbin_exprop_dummy == 1,1,0) 
main.df$korbin_all_dummy.lag1 <- if_else(main.df$korbin_cov_exp_dummy.lag1 == 1 | main.df$korbin_exprop_dummy.lag1 == 1,1,0) 

#Models
test1d.korbin <- lfe::felm(korbin_exprop_dummy ~pop.leader.blair.lag1*exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) + res_gdp.lag1  +
                             gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + korbin_exprop_dummy.lag1  + pop.land.ratio.lag1+
                             is.democ.lag1 + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data =  main.df)

test1d.korbin.cov <- lfe::felm(korbin_cov_exp_dummy ~ pop.leader.blair.lag1*exec.ecopref.lag1 + exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) + res_gdp.lag1  +
                                 gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + korbin_cov_exp_dummy.lag1  + pop.land.ratio.lag1+
                                 is.democ.lag1 + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data =  main.df)

test1d.korbin.all <- lfe::felm(korbin_all_dummy ~pop.leader.blair.lag1*exec.ecopref.lag1+ exec.ecopref.lag1 + log(pop.lag1) + log(gdp.lag1) + res_gdp.lag1  +
                                 gdp.growth.wb.lag1 + fdi.gdp.lag1 + trade.openness.lag1 + active.imfloans.lag1 + korbin_all_dummy.lag1  + pop.land.ratio.lag1+
                                 is.democ.lag1 + net.inforce.bits.lag1 |ccode.cow + year|0|ccode.cow,data =  main.df)

#Make Table
stargazer(test1d.korbin.all,test1d.korbin,test1d.korbin.cov,type = 'html',title = 'Effect of Populism on Expropriation using Kobrin Data, 1990-2014',
          label = 'kobrin.res.tab', keep.stat = c('n','rsq'),font.size = 'scriptsize',dep.var.caption = "",dep.var.labels.include = F,
          column.labels = c('All Korbin Exprop Dummy','Overt Exprop. Dummy','Covert Exprop. Dummy'),
          order = c(1,2,16,3,4,5,6,7,8,9,10,11,12,13,14,15),no.space = T,
          covariate.labels = c("Populist Leader$_{t-1}$","Economic Ideology$_{t-1}$","Populist Leader$_{t-1}$ X \\text{Economic Ideology}$_{t-1}$",
                               "Log Population$_{t-1}$","Log GDP$_{t-1}$","Natural Resource Rents/GDP$_{t-1}$","GDP Growth$_{t-1}$","FDI/GDP$_{t-1}$","Trade Openness$_{t-1}$","Active IMF Loan$_{t-1}$",
                               "All Exprop. Dummy$_{t-1}$","Overt Exprop. Dummy$_{t-1}$","Covert Exprop. Dummy$_{t-1}$","Population/Land$_{t-1}$","Democracy$_{t-1}$","Num BITs Total$_{t-1}$",'Former Communist$_{t-1}$'),
          add.lines = list(c('Country Fixed Effects','Yes','Yes','Yes'),c('Year Fixed Effects','Yes','Yes','Yes')),
          out = 'Tables//TableB8.doc')

#####Table B9 (Appendix)######

#I use same models as in Table 2

stargazer(mech1.res.blair,mech1.res.dpi,mech2.growth.blair,mech2.growth.dpi,type = 'html',
          title = 'Costs of Expropriation Moderate Left Populists Propensity to Expropriate',
          label = 'cost_exp', keep.stat = c('n','rsq'),font.size = 'scriptsize',dep.var.caption = "",dep.var.labels.include = F,
          column.labels = c('Nat. Resources','Nat. Resources','Growth','Growth'),no.space = T,
          covariate.labels = c("Left Populist Leader (Blair)$_{t-1}$","Left Populist Leader (DPI)$_{t-1}$","Log Natural Resource Rents/GDP$_{t-1}$",
                               "Expropriation Dummy$_{t-1}$","Num BITs Total$_{t-1}$","Log Population$_{t-1}$","Log GDP$_{t-1}$",
                               "GDP Growth$_{t-1}$","FDI/GDP$_{t-1}$", "Trade Openness$_{t-1}$","Active IMF Loan$_{t-1}$","Population/Land$_{t-1}$","Democracy$_{t-1}$",
                               "Left Populist Leader (Blair)$_{t-1}$ X \\text{Log Natural Resource Rents/GDP}$_{t-1}$",
                               "Left Populist Leader (DPI)$_{t-1}$ X \\text{Log Natural Resource Rents/GDP}$_{t-1}$",
                               "Left Populist Leader (Blair)$_{t-1}$ X \\text{GDP Growth}$_{t-1}$",
                               "Left Populist Leader (DPI)$_{t-1}$ X \\text{GDP Growth}$_{t-1}$"),
          add.lines = list(c('Country Fixed Effects','Yes','Yes','Yes','Yes'),c('Year Fixed Effects','Yes','Yes','Yes','Yes')),
          out = 'Tables//TableB9.doc')

#####Figure B5 and B6 (Appendix)######

#Main Specification
out.fect <- fect(foreign.exp.dummy ~ left_pop_blair + log(pop.lag1) + log(gdp.lag1)    +log.res_gdp.lag1 + 
                   gdp.growth.wb.lag1 + trade.openness.lag1 + fdi.gdp.lag1  + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                   is.democ.lag1 + net.inforce.bits.lag1, data = main.df, index = c("ccode.cow","year"), na.rm = T,
                 force = "two-way", se = TRUE, parallel = TRUE, nboots = 200,method = "mc", CV = TRUE,seed = 1234)

out.fect$est.avg

plot(out.fect, main = "Estimated ATT (MC)", ylab = "Effect of Left Populist Leader on Expropriation", 
     cex.main = 0.8, cex.lab = 0.8, cex.axis = 0.8)

ggsave('Figures//FigureB5.jpg',width = 7,height = 5)


plot(out.fect, type = "equiv", ylim = c(-0.05,0.05), ylab = "Effect on Expropriation",
     cex.legend = 0.6, main = "Testing Pre-Trend (MC)", cex.text = 0.8)

ggsave('Figures//FigureB6.jpg',width = 7,height = 5)

#Alternative measure using DPI as robustness

out.fect.dpi <- fect(foreign.exp.dummy ~ left_pop_dpi + log(pop.lag1) + log(gdp.lag1)    +log.res_gdp.lag1 + 
                       gdp.growth.wb.lag1 + trade.openness.lag1 + fdi.gdp.lag1  + active.imfloans.lag1 + foreign.exp.dummy.lag1  + pop.land.ratio.lag1+
                       is.democ.lag1 + net.inforce.bits.lag1, data = main.df, index = c("ccode.cow","year"), na.rm = T,
                     force = "two-way", se = TRUE, parallel = TRUE, nboots = 200,method = "mc", CV = TRUE,seed = 1234)

out.fect.dpi$est.avg


#####Table C1 (Appendix)######

#Models
modC1.a <- lfe::felm(left_pop_blair ~ res_gdp_ihs.lag1 + fdi_inflow_ihs.lag1 +net.inforce.bits.lag1.ihs + ln.total.trade.lag1+log(gdp.lag1)+ log(pop.lag1) + 
                      active.imfloans.lag1 + left_pop_blair.lag1 +
                      cum.cases.isds.lag1 + log(pop.lag1) + log(gdp.lag1) + gdp.growth.wb.lag1 + 
                      pop.land.ratio.lag1 + is.democ.lag1 |ccode.cow + year|0|ccode.cow,data = main.df)

modC1.b <- lfe::felm(pop.leader.blair ~ res_gdp_ihs.lag1 + fdi_inflow_ihs.lag1 + net.inforce.bits.lag1.ihs + ln.total.trade.lag1+ log(pop.lag1) + log(gdp.lag1) +
                      active.imfloans.lag1 + pop.leader.blair.lag1 +
                      cum.cases.isds.lag1 + log(pop.lag1) + log(gdp.lag1) + gdp.growth.wb.lag1 + 
                      pop.land.ratio.lag1 + is.democ.lag1|ccode.cow + year|0|ccode.cow,data = main.df)

modC1.c <- lfe::felm(left_pop_dpi ~ res_gdp_ihs.lag1 + fdi_inflow_ihs.lag1 + net.inforce.bits.lag1.ihs + ln.total.trade.lag1+ log(pop.lag1) + log(gdp.lag1) +
                      active.imfloans.lag1  +left_pop_dpi.lag1+
                      cum.cases.isds.lag1 + log(pop.lag1) + log(gdp.lag1) + gdp.growth.wb.lag1 + 
                      pop.land.ratio.lag1 + is.democ.lag1 |ccode.cow + year|0|ccode.cow,data = main.df)

#Make Table
stargazer(modC1.a,modC1.b,modC1.c,type = 'html',keep.stat = c('n','rsq'),font.size = 'scriptsize',dep.var.caption = "",
          dep.var.labels = c('Pop. Leader','Left. Pop. Leader','Left. Pop. Leader DPI'),no.space = T,
          covariate.labels = c("Natural Resource Rents/GDP$_{t-1}$","FDI Inflow$_{t-1}$","Num BITs Total$_{t-1}$",
                               "Log Total Trade$_{t-1}$","Log Population$_{t-1}$","Log GDP$_{t-1}$","Active IMF Loan$_{t-1}$",
                               "Populist Leader$_{t-1}$","Left Pop. Leader$_{t-1}$","Left Pop. Leader DPI$_{t-1}$",
                               "ISDS Cases$_{t-1}$","GDP Growth$_{t-1}$",
                               "Population/Land$_{t-1}$","Democracy$_{t-1}$"),
          add.lines = list(c('Country Fixed Effects','Yes','Yes','Yes'),c('Year Fixed Effects','Yes','Yes','Yes')),
          out = 'Tables//TableC1.doc')



